import React, { useEffect, useState } from 'react';
import { Layout, Table, Typography } from 'antd';
import { getExaminationMessageAPI, getMockExaminationMessageAPI } from '@/api/student';
import { getUserId } from '@/utils/userId';
const { Content } = Layout;
const { Title } = Typography;

const Exam = () => {
  const dataSource = [
    {
      key: '1',
      studentName: '张三',
      examDate: '2024-04-10',
      subject: '科目一',
      score: 95,
    },
    {
      key: '2',
      studentName: '张三',
      examDate: '2024-04-21',
      subject: '科目二',
      score: 90,
    },
    // 其他学员数据...
  ];

  // 考试表格列配置
  const examColumns = [
    {
      title: '学员姓名',
      dataIndex: 'studentName',
      key: 'studentName',
    },
    {
      title: '考试日期',
      dataIndex: 'examDate',
      key: 'examDate',
    },
    {
      title: '科目',
      dataIndex: 'examinationName',
      key: 'examinationName',
    },
    {
      title: '成绩',
      dataIndex: 'examinationScore',
      key: 'examinationScore',
    },
  ];
  //模拟考试
  const mockExamColumns = [
    {
      title: '学员姓名',
      dataIndex: 'mockStudentName',
      key: 'mockStudentName',
    },
    {
      title: '考试日期',
      dataIndex: 'mockExamDate',
      key: 'mockExamDate',
    },
    {
      title: '科目',
      dataIndex: 'mockExaminationName',
      key: 'mockExaminationName',
    },
    {
      title: '成绩',
      dataIndex: 'mockExaminationScore',
      key: 'mockExaminationScore',
    },
  ];
  //存储考试成绩
  const [examination,setExamination] = useState([])
  //存储模拟考试成绩
  const [mockExamination,setMockExamination] = useState([])
  //获取考试成绩
  useEffect(()=>{
    async function getExamination(){
      const mockExamData = await getMockExaminationMessageAPI(getUserId())
      const exam =await getExaminationMessageAPI(getUserId())
      if(mockExamData !== '')
      setMockExamination(mockExamData.data)
    if(exam !== '')
      setExamination(exam.data)
    }
    getExamination()
  },[])

  return (
    <Layout style={{ minHeight: '100vh' }}>
      <Content style={{ padding: '50px' }}>
        <Title level={2}>考试成绩</Title>
        <Table dataSource={examination} columns={examColumns} />
        <Title level={2}>模拟考试成绩</Title>
        <Table dataSource={mockExamination} columns={mockExamColumns} />
      </Content>
    </Layout>
  );
};

export default Exam;